package com.wzf.ohc;

import com.wzf.utils.OhcProtostuffObjectSerializer;
import com.wzf.utils.OhcStringSerializer;
import org.caffinitas.ohc.Eviction;
import org.caffinitas.ohc.OHCache;
import org.caffinitas.ohc.OHCacheBuilder;

public class OHCFactory {


    public  static  final OHCache<String, Object> basicStoreInfoCache = OHCacheBuilder.<String, Object>newBuilder()
            .keySerializer(new OhcStringSerializer()) //key的序列化器
            .valueSerializer(new OhcProtostuffObjectSerializer()) //value的序列化器
            .segmentCount(512) // 分段数量 默认=2*CPU核数
            .hashTableSize(100000)// 哈希表大小 默认=8192
            .capacity(1024 * 1024 * 1024) //缓存容量 单位B 默认64MB
            .eviction(Eviction.LRU) // 淘汰策略 可选LRU\W_TINY_LFU\NONE
            .timeouts(false) //不使用过期时间，根据业务自己选择
            .build();

}
